<template>
	<view style="padding: 40rpx;">
		<u-navbar style="margin-top: 10px;" :autoBack="true" :safeAreaInsetTop="true" :placeholder="true" :fixed="true">
			<view slot="left">
				<u-icon name="arrow-left" size="28"></u-icon>
			</view>
			<view slot="center">
				<text>自测记录</text>
			</view>
		</u-navbar>
		<view v-for="(item, index) in recordData" :key="checkId"
			style="display: flex;justify-content: space-between;margin-bottom: 20rpx;" @click="() => onRecord(item)">
			<u-icon name="clock" size="18"  color="#37B874"></u-icon>
			<view>{{ item.insertDate }}</view>
			<view>成绩：{{ item.scoreInt || 0 }}</view>
			<u-icon name="arrow-right" size="18"></u-icon>
		</view>
	</view>
</template>

<script>
import { listHisChecks } from '../../services/PracticeTestingService';
import { listHisChecksPaper } from '../../services/QuestionBankService';
export default {
	data() {
		return {
			recordData: [],
			isPaper: false,
			marketId: ''
		}
	},
	onLoad(option) {
		this.isPaper = option.isPaper ? JSON.parse(option.isPaper) : ''
		this.marketId = option.marketId || ''
		console.log(option, 'option', this.isPaper);

		this.onListHisChecks(option.outLineTestId, option.id)
	},
	onShow() {

	},
	methods: {
		onListHisChecks(outLineTestId, id) {
			if (this.isPaper) {
				listHisChecksPaper({ marketId: this.marketId }).then(res => {
					this.recordData = res
				})
			} else {
				listHisChecks({ outLineTestId, id }).then(res => {
					this.recordData = res
				})
			}

		},
		onRecord(item) {
			uni.navigateTo({
				url: '/pages/practiceTesting/selfTestingPage?flag=' + true + '&checkId=' + item.checkId
			})
		}
	}

}
</script>

<style>
page {
	background-color: #FFF !important;
}
</style>